package com.v9.flow.util;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;

/**
 * 表单元素*
 *
 * @author lunshi
 */
@Data
public class FormField {
    @Schema(description = "表单项", required = true)
    private String name;
    @Schema(description = "是否必填", required = true)
    private Boolean request;
    @Schema(description = "提供器", required = true)
    private FormProviderEnum provider;
    @Schema(description = "提供器编码", required = false)
    private String providerCode;
    private Integer maxLength;
    private Integer minLength;
    private Number maxValue;
    private Number minValue;

    FormField() {


    }
    /**
     * * 表单
     *
     * @param name 表单属性
     */
    FormField(String name) {
        this.name = name;
        this.request = false;
        this.provider = FormProviderEnum.TextProvider;
    }
    /**
     * * 表单
     *
     * @param name 表单属性
     */
    FormField(String name, Boolean request) {
        this.name = name;
        this.request = request;
        this.provider = FormProviderEnum.TextProvider;
    }

    /**
     * * 表单
     *
     * @param name         属性
     * @param request      必填
     * @param providerType 提供类型
     */
    public FormField(String name, Boolean request, FormProviderEnum providerType) {
        this.name = name;
        this.request = request;
        this.provider = providerType;
    }

    /**
     * * 表单
     *
     * @param name         属性
     * @param request      必填
     * @param providerType 提供类型
     * @param providerCode 提供器编码
     */
    FormField(String name, Boolean request, FormProviderEnum providerType, String providerCode) {
        this.name = name;
        this.request = request;
        this.provider = providerType;
        this.providerCode = providerCode;

    }

    /**
     * * 表单
     *
     * @param name      属性名
     * @param minLength 最小字符
     * @param maxLength 最大字符
     */
    FormField(String name, Boolean request, Integer minLength, Integer maxLength) {
        this.name = name;
        this.request = request;
        this.provider = FormProviderEnum.TextProvider;
        this.minLength = minLength;
        this.maxLength = maxLength;
    }

    /**
     * 表单*
     *
     * @param name     名称
     * @param minValue 最小值
     * @param maxValue 最大值
     */
    FormField(String name, Boolean request, BigDecimal minValue, BigDecimal maxValue) {
        this.name = name;
        this.request = request;
        this.provider = FormProviderEnum.DecimalProvider;
        this.minValue = minValue;
        this.maxValue = maxValue;
    }

    /**
     * 表单*
     *
     * @param name     名称
     * @param minValue 最小值
     * @param maxValue 最大值
     */
    FormField(String name, Boolean request, Long minValue, Long maxValue) {
        this.name = name;
        this.request = request;
        this.provider = FormProviderEnum.IntegerProvider;
        this.minValue = minValue;
        this.maxValue = maxValue;
    }


}
